%premiumTooltip {
  @include mask('icon-premium', $textColorInverted, 14px);
  position: relative;
  display: inline-block;
  font-size: 90%;
  height: 26px;
  line-height: 26px;
  padding: 0 4px 0 22px;
  vertical-align: top;
  color: $textColorInverted;
  background: $__textColor;

  &::after {
    content: "";
    position: absolute;
    top: 5px;
    right: -16px;
    border: 8px solid transparent;
    border-left-color: $__textColor;
  }

  &::before {
    -webkit-mask-position-x: 4px;
  }
}

body > a.edit {
  @include mask('icon-edit', $textColorLight, 24px);
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 42px;
  height: 42px;
  display: block;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s;

  &:hover {
    background: darken($bodyBackground, 5%);
  }
}

menu.infoBar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: $__textColor;
  padding: 15px 20px;
  transition: transform 0.5s;
  transform: translate3d(0, 60px, 0);
  display: flex;
  justify-content: flex-end;
  align-items: center;

  > a {
    display: block;
    cursor: pointer;

    &.save {
      background: $contentBackground;
      padding: 4px 8px;
      font-weight: $__fontWeightMedium;
      font-size: 100%;
      border-radius: 5px;
      box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    }

    &.cancel {
      color: $textColorInverted;
      margin: 0 20px;
      padding: 5px 3px;
    }
  }

  > div.upload {
    @extend %hidden;
    position: absolute;
    top: -60px;
    right: 20px;
    transform: translate3d(0, 30px, 0);
    transition: transform 0.5s, opacity 0.5s;

    > a.remove {
      @include mask('icon-delete', $__textColor, 18px);
      position: relative;
      display: none;
      background: $contentBackground;
      box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
      border-radius: 50%;
      width: 32px;
      height: 32px;
      cursor: pointer;
    }

    > div {
      position: relative;
      overflow: hidden;
      display: inline-block;
      background: $contentBackground;
      padding: 0 8px;
      margin: 0 0 0 10px;
      height: 32px;
      line-height: 32px;
      font-weight: $__fontWeightMedium;
      font-size: 100%;
      border-radius: 5px;
      box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);

      > span {
        @include mask('settings/icon-screenshot', $__textColor, 20px);
        position: relative;
        padding: 0 3px 0 28px;

        &::before {
          -webkit-mask-position-x: 0;
        }
      }

      > input[type='file'] {
        position: absolute;
        top: 0;
        left: -900%;
        width: 1000%;
        height: 100%;
        cursor: pointer;
        outline: none;
      }
    }

    > span.premium {
      @extend %premiumTooltip;
      margin: 2px 0 0 10px;
    }
  }
}

div.editLinkTooltip {
  position: absolute;
  text-align: left;
  background: $contentBackground;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.1));
  padding: 10px;
  bottom: -170px;
  right: -10px;
  height: 160px;
  width: 250px;
  border-radius: 3px;
  z-index: 9;

  &::before {
    content: "";
    position: absolute;
    top: -20px;
    right: 20px;
    width: 0;
    border: 10px solid transparent;
    border-bottom-color: $contentBackground;
  }

  > label {
    font-weight: $__fontWeightMedium;
    display: block;
  }

  > input[type='text'] {
    outline: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: transparent;
    display: block;
    width: 100%;
    margin: 3px 0 10px;
    padding: 5px;

    &:focus {
      border-color: rgba(0, 0, 0, 0.25);
    }
  }

  > button[type='submit'] {
    border: none;
    outline: none;
    background: none;
    color: $__colorScheme;
    font-weight: $__fontWeightMedium;
    cursor: pointer;
    float: right;
    margin-top: 3px;

    &[data-type="delete"] {
      float: left;
      color: $textColorLight;
    }
  }
}

body[data-pos='right'] {

  > a.edit {
    right: auto;
    left: 20px;
  }

  menu.infoBar {
    justify-content: flex-start;

    > a {

      &.save {
        order: 1;
      }

      &.cancel {
        order: 2;
      }
    }

    > div.upload {
      right: unset;
      left: 20px;

      > a.remove {
        float: right;
      }

      > div {
        margin: 0 10px 0 0;
      }

      > span.premium {
        margin-left: 0;
        margin-right: 10px;
        float: right;

        &::after {
          right: unset;
          left: -16px;
          border-left-color: transparent;
          border-right-color: $__textColor;
        }

        &::before {
          -webkit-mask-position-x: 4px;
        }
      }
    }
  }
}

body.customBackground {

  menu.infoBar {

    > div.upload {

      > a.remove {
        display: inline-block;
      }
    }
  }

  > a.edit {
    background: rgba($bodyBackground, 0.8);

    &::before {
      background-color: darken($textColorLight, 15%);
    }
  }
}

body.edit {

  > a.edit {
    display: none;
  }

  select.edit {
    display: block;
    background: $contentBackground;
    height: 25px;
    margin: 0 auto;
    border-radius: 10px;
    padding: 0 7px;
    border: none;
    outline: none;
    cursor: pointer;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
  }

  menu.infoBar {
    transform: translate3d(0, 0, 0);

    > div.upload {
      @extend %visible;
      transform: translate3d(0, 0, 0);
    }
  }

  section#content {
    height: calc(100vh - 60px);

    > nav {

      select.edit {
        margin-top: 15px;
      }

      > a.add {
        @include mask('icon-add', $textColorLight, 20px);
        position: absolute;
        display: block;
        width: 30px;
        height: 30px;
        top: 0;
        left: 0;
        background: $bodyBackground;
        transition: background 0.3s;
        border-radius: 50%;
        cursor: pointer;

        &:hover {
          background: darken($bodyBackground, 5%);
        }
      }

      > ul > li {

        > a {
          @include mask('icon-edit', $textColorLight, 14px);
          border: 2px dashed $textColorLight;
          padding-top: 5px;
          padding-bottom: 21px;
          border-radius: 10px;
          font-size: 90%;
          margin-left: 3px;
          margin-right: 3px;
          min-width: 50px;

          &::before {
            height: 16px;
            bottom: 3px;
            top: unset;
          }

          &:hover {
            background: rgba(0, 0, 0, 0.05);
          }

          &.dragHover {
            opacity: 0.3;
          }
        }
      }

      &[data-pos='left'] {

        > a.add {
          right: 0;
          left: unset;
        }

        > ul > li {

          div.editLinkTooltip {
            left: -10px;
            right: unset;

            &::before {
              left: 20px;
              right: unset;
            }
          }
        }
      }
    }
  }

  form#search {

    &.hidden {
      display: block;

      > input[type='text'] {
        opacity: 0.5;
      }

      > div[data-name='searchSuggest'] {
        opacity: 0.5;
      }
    }

    > select.edit {
      margin-top: -56px;
      margin-bottom: 31px;
    }

    > div[data-name='searchSuggest'] {
      position: absolute;
      top: -25px;
      width: 100%;
      text-align: center;

      > div.checkbox {
        display: inline-block;

        &::before {
          -webkit-mask-size: 18px;
        }

        + span {
          font-size: 90%;
          font-weight: $__fontWeightMedium;
          vertical-align: top;
          display: inline-block;
          margin: 3px 20px 0 5px;
        }
      }
    }

    > input[type='text'] {
      padding-right: 125px;
    }

    > button[type="submit"], > a.speechSearch {
      display: none;
    }

    > a.edit {
      @include mask('icon-edit', $textColorLight, 22px);
      right: 20px;
      width: calc(#{$newTabSearchHeight} - 14px);
      height: calc(#{$newTabSearchHeight} - 14px);
    }
  }

  div#gridLinks {
    margin-top: 25px !important;

    > select.edit {
      display: inline-block;
      margin: 0 7px;
    }

    > div[data-type='gridsize'] {
      display: inline-block;
      margin: 0 10px;

      > strong {
        font-weight: $__fontWeightNormal;
        margin: 0 5px 0 0;
      }

      > span {
        margin: 0 3px;
      }

      > select.edit {
        display: inline-block;
        padding: 0;
        height: 22px;
        font-size: 90%;
      }

      > span.premium {
        @extend %premiumTooltip;
        margin: -2px 0 0 14px;

        &::after {
          transform: scale(-1);
          left: -16px;
          right: unset;
        }
      }

      &.premium {

        > select.edit {
          color: $textColorLight;
          box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
          opacity: 0.7;
          cursor: not-allowed;

          > option {
            display: none;
          }
        }
      }
    }

    &[data-type="custom"] {

      > ul > li {

        div.editLinkTooltip {
          bottom: -125px;
          left: -52px;
          right: unset;

          &::before {
            left: 0;
            right: 0;
            margin: auto;
          }
        }

        > a {
          visibility: visible;
          border: 2px solid transparent;

          > * {
            pointer-events: none;
          }

          > div {
            @include mask('icon-edit', $textColorLight, 18px);
            box-shadow: none;
            border: 2px dashed $textColorLight;
            background: transparent;
            cursor: pointer;
            transition: background 0.3s;

            > img {
              visibility: hidden;
            }
          }

          &:hover > div {
            background: rgba(0, 0, 0, 0.05);
          }

          &.dragHover {
            border: 2px dashed $textColorLight;

            > * {
              opacity: 0.3;
            }
          }

          &[data-value='empty'] > div::before {
            @include maskImage('icon-add');
          }
        }
      }
    }
  }

  &.customBackground {

    select.edit {
      background: rgba($contentBackground, 0.8);
    }

    &.edit {

      div#gridLinks {

        > div[data-type='gridsize'] {
          background: rgba($contentBackground, 0.8);
          border-radius: 10px;
          padding: 2px 8px 1px 10px;
          margin: 0 7px;
        }

        &[data-type="custom"] > ul > li > a {

          > div {
            background: rgba($contentBackground, 0.8);
            box-shadow: 0 0 0 3px rgba($contentBackground, 0.8);
            border-color: $__textColor;

            &::before {
              background: $__textColor;
            }
          }

          &:hover > div {
            background: rgba($contentBackground, 0.9);
          }

          &.dragHover {
            border-color: $contentBackground;

            > * {
              opacity: 0.5;
            }
          }
        }
      }

      section#content > nav {

        > a.add::before {
          background: $__textColor;
        }

        > ul > li > a {
          background: rgba($contentBackground, 0.8);
          box-shadow: 0 0 0 3px rgba($contentBackground, 0.8);
          border-color: $__textColor;

          &::before {
            background: $__textColor;
          }

          &:hover {
            background: rgba($contentBackground, 0.9);
          }

          &.dragHover {
            opacity: 0.5;
          }
        }
      }
    }
  }
}

@import "../../rtl/include/newtab/edit";
@import "../../dark/include/newtab/edit";